package com.espeaker.sdk.api;

import org.json.JSONObject;

import com.espeaker.sdk.ESpeakerParameters;
import com.espeaker.sdk.NetException;
import com.espeaker.sdk.net.HttpManager;
public class LogApi {
	protected static final String URL_BASE = "http://log.miao.yishuodian.com/8d70e0d1acb06b4648c7aa8927509660/";
	
	protected static final String LOG_APP_LAUNCH="app-launch";
	
	protected static final String LOG_ACCOUNT="account";
	
	protected static final String LOG_CART="cart";
	
	protected static final String LOG_CLICK="click-flow";
	
	protected static final String LOG_DEVICE="device";
	
	protected static final String LOG_LOGIN="login";
	
	protected static final String LOG_RECORD="record";
	
	protected static final String DataSource="android";
	/*
	 * 网络数据请求
	 */
	protected String request(final String url, final String api_method,
			final ESpeakerParameters params) {
		String rlt = "";
		
		JSONObject json = new JSONObject();
		for (int i = 0; i < params.size(); i++) {
				try {
					if(params.isSign(params.getKey(i))){
						json.put(params.getKey(i), params.getValue(i));
					}
				} catch (Exception er) {
			}
		}
		
		String newUrl = url +api_method ;
		
		for (int i = 0; i < params.size(); i++) {
			try {
				if(!params.isSign(params.getKey(i))){
					json.put(params.getKey(i), params.getValue(i));
				}
			} catch (Exception er) {
		}
	}
		try {
			rlt = HttpManager.openPostUrl(newUrl,json);
			System.out.println("<================================rlt======"+rlt);
		} catch (NetException er) {
		}
		return rlt;
	}
	
}
